/*
Copyright [2023] [fuwen_soft]
*/
package vip.xiaonuo.modular.xyserver.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.modular.xyserver.param.XyServerParam;
import vip.xiaonuo.modular.xyserver.service.XyServerService;
import vip.xiaonuo.modular.xyserver.entity.XyServer;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.core.annotion.version.AdminVersionSwagger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.List;
import vip.xiaonuo.sys.core.msg.Result;
import static vip.xiaonuo.sys.core.msg.ResultUtils.success;
/**
 * 服务相关控制器
 *
 * @author yanwei
 * @date 2023-05-10 17:35:38
 */
@RestController
@Api(tags = "后台管理 服务相关 相关APIS")
@AdminVersionSwagger
public class XyServerController {

    @Resource
    private XyServerService xyServerService;

    /**
     * 查询服务相关
     *
     * @author yanwei
     * @date 2023-05-10 17:35:38
     */
    @Permission
    @GetMapping("/xyServer/page")
    @BusinessLog(title = "服务相关_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("服务相关_查询")
    public Result<PageResult<XyServer>> page(XyServerParam xyServerParam) {
        PageResult<XyServer> page = xyServerService.page(xyServerParam);
        return success(page);
    }

    /**
     * 添加服务相关
     *
     * @author yanwei
     * @date 2023-05-10 17:35:38
     */
    @Permission
    @PostMapping("/xyServer/add")
    @BusinessLog(title = "服务相关_增加", opType = LogAnnotionOpTypeEnum.ADD)
    @ApiOperation("服务相关_增加")
    public Result add(@RequestBody @Validated(XyServerParam.add.class) XyServerParam xyServerParam) {
            xyServerService.add(xyServerParam);
        return success();
    }

    /**
     * 删除服务相关，可批量删除
     *
     * @author yanwei
     * @date 2023-05-10 17:35:38
     */
    @Permission
    @PostMapping("/xyServer/delete")
    @BusinessLog(title = "服务相关_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation("服务相关_删除")
    public Result delete(@RequestBody @Validated(XyServerParam.delete.class) List<XyServerParam> xyServerParamList) {
            xyServerService.delete(xyServerParamList);
        return success();
    }

    /**
     * 编辑服务相关
     *
     * @author yanwei
     * @date 2023-05-10 17:35:38
     */
    @Permission
    @PostMapping("/xyServer/edit")
    @BusinessLog(title = "服务相关_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    @ApiOperation("服务相关_编辑")
    public Result edit(@RequestBody @Validated(XyServerParam.edit.class) XyServerParam xyServerParam) {
            xyServerService.edit(xyServerParam);
        return success();
    }

    /**
     * 查看服务相关
     *
     * @author yanwei
     * @date 2023-05-10 17:35:38
     */
    @Permission
    @GetMapping("/xyServer/detail")
    @BusinessLog(title = "服务相关_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    @ApiOperation("服务相关_查看")
    public Result<XyServer> detail(@Validated(XyServerParam.detail.class) XyServerParam xyServerParam) {
        XyServer detail =   xyServerService.detail(xyServerParam);
        return success(detail);
    }

    /**
     * 服务相关列表
     *
     * @author yanwei
     * @date 2023-05-10 17:35:38
     */
    @Permission
    @GetMapping("/xyServer/list")
    @BusinessLog(title = "服务相关_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("服务相关_列表")
    public Result<List<XyServer>> list(XyServerParam xyServerParam) {
        List<XyServer> list  =   xyServerService.list(xyServerParam);
        return success(list);
    }

    /**
     * 导出系统用户
     *
     * @author yanwei
     * @date 2023-05-10 17:35:38
     */
    @Permission
    @GetMapping("/xyServer/export")
    @BusinessLog(title = "服务相关_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
    @ApiOperation("服务相关_导出")
    public void export(XyServerParam xyServerParam) {
        xyServerService.export(xyServerParam);
    }

}
